package com.sise.rsc.repository;

import com.sise.rsc.entity.PackageAction;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface PackageActionRepository extends JpaRepository<PackageAction,Integer> {

    //通过年份月份查找某一个快递员当月的收件量
    @Query("from PackageAction test where test.state=2 and test.courier.id=:courierId and year(test.time)=:year and month(test.time)=:month ")
    List<PackageAction> findThisMonthFetchNumByCourierId(int courierId, int year, int month);

    //通过年份月份查找某一个快递员当月的派件量
    @Query("from PackageAction test where test.state=0 and test.courier.id=:courierId and year(test.time)=:year and month(test.time)=:month ")
    List<PackageAction> findThisMonthDeliverNumByCourierId(int courierId, int year, int month);

    //通过快递号查找包裹的所有经历Action
    @Query("from PackageAction pa where pa.aPackage.no=:pNo")
    List<PackageAction> findAllActionByPackageNo(String pNo);
}
